package com.lyl.syt.receiver;

import cn.hutool.core.date.DateUtil;
import com.lyl.syt.rabbit.constant.MqConstant;
import com.lyl.syt.service.OrderService;
import com.rabbitmq.client.Channel;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * @author Mr.Luo
 * @date 2022-05-27 11:21
 * @desc 接受发送就医提醒的消息
 */
@Slf4j
@Component
@RequiredArgsConstructor
public class OrderReceiver {
    private final OrderService orderService;

    @RabbitListener(bindings = {@QueueBinding(
            value = @Queue(value = MqConstant.TASK_QUEUE,durable = "true"),
            exchange = @Exchange(value = MqConstant.TASK_EXCHANGE),
            key = MqConstant.TASK_ROUTING
    )})
    public void patientTips(Message message, Channel channel){
        log.info("就医提醒任务开始执行 : {}", DateUtil.now());
        orderService.patientTips();
    }
}
